<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
// 作业1：有以下某公司员工薪金信息，把每一位员工的salary薪金信息 加 2000，并返回新数组，注意：不影响原数组
let persons = [
    {
        username:'张飞',
        sex:'男',
        salary:20000
    },
    {
        username:'关羽',
        sex:'男',
        salary:30000
    }
]

let newpersons= persons.map(function(item){

    // console.log(item.salary);
    // item.salary+=2000

    // return item
    /* return {
        username:'张飞',
        sex:'男',
        salary:item.salary+2000
    } */
    return {
        ...persons,
        salary:item.salary+2000
    }
})
console.log(newpersons);
console.log(persons);





</script>